
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Android底层软硬件结合开发概述 · GItBook笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="cpucode">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../operating_system/operat_mechanism.html" />
    
    
    <link rel="prev" href="AOSP.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://blog.csdn.net/qq_44226094" target="_blank" class="custom-link">首页</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    目录
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Linux驱动开发</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../linux_driver/character_device_driver.html">
            
                <a href="../linux_driver/character_device_driver.html">
            
                    
                    字符设备驱动开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../linux_driver/linux_driver.html">
            
                <a href="../linux_driver/linux_driver.html">
            
                    
                    Linux驱动开发
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">安卓底层开发</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="hardware_abstraction_layer.html">
            
                <a href="hardware_abstraction_layer.html">
            
                    
                    硬件抽象层
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="smart_pointer.html">
            
                <a href="smart_pointer.html">
            
                    
                    智能指针
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="AOSP.html">
            
                <a href="AOSP.html">
            
                    
                    AOSP源码开发
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="3.4" data-path="summary.html">
            
                <a href="summary.html">
            
                    
                    Android底层软硬件结合开发概述
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">操作系统</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../operating_system/operat_mechanism.html">
            
                <a href="../operating_system/operat_mechanism.html">
            
                    
                    操作系统的运行机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../operating_system/process.html">
            
                <a href="../operating_system/process.html">
            
                    
                    进程
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">linux一句话</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../linux_in_a_word/network_indepen.html">
            
                <a href="../linux_in_a_word/network_indepen.html">
            
                    
                    与网络无关的Linux
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Linux内核0.12</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../linux_kernel_0_12/computer_composition.html">
            
                <a href="../linux_kernel_0_12/computer_composition.html">
            
                    
                    微型计算机组成结构
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Android底层软硬件结合开发概述</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <!--
 * @Author: cpu_code
 * @Date: 2020-07-11 16:18:27
 * @LastEditTime: 2020-07-12 21:08:49
 * @FilePath: \note\android_bottom\summary.md
 * @Gitee: https://gitee.com/cpu_code
 * @Github: https://github.com/CPU-Code
 * @CSDN: https://blog.csdn.net/qq_44226094
 * @Gitbook: https://923992029.gitbook.io/cpucode/
--> 
<h1 id="android&#x5E95;&#x5C42;&#x8F6F;&#x786C;&#x4EF6;&#x7ED3;&#x5408;&#x5F00;&#x53D1;&#x6982;&#x8FF0;">Android&#x5E95;&#x5C42;&#x8F6F;&#x786C;&#x4EF6;&#x7ED3;&#x5408;&#x5F00;&#x53D1;&#x6982;&#x8FF0;</h1>
<ul>
<li>@Author: cpu_code</li>
<li>@Date: 2020-07-11 16:18:27</li>
<li>@LastEditTime: 2020-07-12 21:08:41</li>
<li>@FilePath: \note\android_bottom\summary.md</li>
<li>@Gitee: <a href="https://gitee.com/cpu_code" target="_blank">https://gitee.com/cpu_code</a></li>
<li>@Github: <a href="https://github.com/CPU-Code" target="_blank">https://github.com/CPU-Code</a></li>
<li>@CSDN: <a href="https://blog.csdn.net/qq_44226094" target="_blank">https://blog.csdn.net/qq_44226094</a></li>
<li>@Gitbook: <a href="https://923992029.gitbook.io/cpucode/" target="_blank">https://923992029.gitbook.io/cpucode/</a></li>
</ul>
<h3 id="android&#x5E95;&#x5C42;&#x8F6F;&#x786C;&#x4EF6;&#x7ED3;&#x5408;&#x5F00;&#x53D1;&#x6982;&#x8FF0;">Android&#x5E95;&#x5C42;&#x8F6F;&#x786C;&#x4EF6;&#x7ED3;&#x5408;&#x5F00;&#x53D1;&#x6982;&#x8FF0;</h3>
<p>Android&#x662F; &#x4E2A;&#x5F00;&#x6E90;&#x7684;&#x667A;&#x80FD;&#x79FB;&#x52A8;&#x5E73;&#x53F0; &#x4E00;&#x4E2A;&#x5F00;&#x6E90;&#x7684;&#x667A;&#x80FD;&#x79FB;&#x52A8;&#x5E73;&#x53F0;&#xFF0C; &#x4EFB;&#x4F55; &#x4E2A;&#x5382;&#x5546;&#x62FF; &#x4E00;&#x4E2A;&#x5382;&#x5546;&#x62FF;&#x5230; Android Source &#x90FD;&#x53EF;&#x4EE5;&#x57FA;&#x4E8E;&#x81EA;&#x5DF1;&#x7684;&#x786C;&#x4EF6;&#x67B6;&#x6784;&#x8BBE;&#x8BA1;</p>
<p>&#x79FB;&#x52A8;&#x8BBE;&#x5907;&#x3002;</p>
<p>&#x786C;&#x4EF6;&#x591A;&#x6837;&#x5316;</p>
<p>&#x5382;&#x5546;&#x81EA;&#x5DF1;&#x7684;&#x5229;&#x76CA;</p>
<p>&#x8F6F;&#x786C;&#x4EF6;&#x7ED3;&#x5408;&#x5F00;&#x53D1;&#x7684;&#x5F0A;&#x7AEF;&#xFF1F;</p>
<p>&#x5931;&#x53BB;&#x4E86;Android&#x5E94;&#x7528;&#x7684;&#x8DE8;&#x5E73;&#x53F0;&#x7279;&#x6027;</p>
<p>&#x7531;&#x4E8E;&#x4E0D;&#x540C;&#x5382;&#x5546;&#x7814;&#x53D1;&#x80FD;&#x529B;&#x53C2;&#x5DEE;&#x4E0D;&#x9F50;&#xFF0C;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x7A33;&#x5B9A;&#x6027;&#x53CA;&#x6027;&#x80FD;&#x6709;&#x6240;&#x4E0D;&#x540C;</p>
<p>&#x5206;&#x7C7B;</p>
<p>NDK&#x5F00;&#x53D1;:</p>
<p>&#x4ECE;&#x5E94;&#x7528;&#x89D2;&#x5EA6;&#x6765;&#x5F00;&#x53D1;&#x8F6F;&#x786C;&#x7ED3;&#x5408;&#x4EE3;&#x7801;</p>
<p> &#x9002;&#x7528;&#x4E8E;&#x5355;&#x4E2A;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x5E95;&#x5C42;&#x7ED3;&#x5408;&#x9700;&#x6C42;</p>
<p>HAL&#x786C;&#x4EF6;&#x62BD;&#x8C61;&#x5C42;&#x5F00;&#x53D1;:</p>
<p>&#x4ECE;&#x6574;&#x4E2A;&#x7CFB;&#x7EDF;&#x6846;&#x67B6;&#x9700;&#x6C42;&#x89D2;&#x5EA6;&#x6765;&#x5F00;&#x53D1;&#x672C;&#x5730;&#x7A0B;&#x5E8F;</p>
<p>&#x9002;&#x7528;&#x4E8E;&#x5171;&#x4EAB;&#x529F;&#x80FD;&#x8F6F;&#x786C;&#x7ED3;&#x5408;&#x4EE3;&#x7801;</p>
<h4 id="hal-&#x6982;&#x5FF5;">HAL &#x6982;&#x5FF5;</h4>
<p>HAL&#xFF08; <strong>Hardware Abstract Layer</strong>&#xFF09;&#x786C;&#x4EF6;&#x62BD;&#x8C61;&#x5C42;&#x662F;Google&#x5F00;&#x53D1;&#x7684;Android&#x7CFB;&#x7EDF;&#x91CC;&#x4E0A;&#x5C42;&#x5E94;&#x7528;&#x5BF9;&#x5E95;&#x5C42;&#x786C;&#x4EF6;&#x64CD;&#x4F5C;&#x5C4F;&#x853D;&#x7684;&#x4E00;&#x4E2A;&#x8F6F;&#x4EF6;&#x5C42;&#x6B21;&#xFF0C;&#x8BF4;&#x767D;&#x4E86;&#xFF0C;&#x5C31;&#x662F;&#x4E0A;&#x5C42;&#x7684;&#x5E94;&#x7528;&#x4E0D;&#x7528;&#x5173;&#x5FC3;&#x5E95;&#x5C42;&#x786C;&#x4EF6;&#x5177;&#x4F53;&#x662F;&#x5982;&#x4F55;&#x5DE5;&#x4F5C;&#x7684;&#xFF0C;&#x53EA;&#x8981;&#x5411;&#x4E0A;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x7EDF;&#x4E00;&#x7684;&#x63A5;&#x53E3;&#x5373;&#x53EF;&#xFF0C;&#x8FD9;&#x79CD;&#x8BBE;&#x8BA1;&#x601D;&#x60F3;&#x5E7F;&#x6CDB;&#x7684;&#x5B58;&#x5728;&#x4E8E;&#x5F53;&#x524D;&#x7684;<strong>&#x8F6F;&#x4EF6;&#x67B6;&#x6784;&#x8BBE;&#x8BA1;</strong>&#x91CC;&#x3002;</p>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706134655.png" alt="image-20200706134655889"></p>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706134701.png" alt="image-20200706134701523"></p>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706134709.png" alt="image-20200706134709193"></p>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706134719.png" alt="image-20200706134718998"></p>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706134646.png" alt="image-20200706134646845"></p>
<p>HAL&#x5B58;&#x5728;&#x7684;&#x539F;&#x56E0;</p>
<p>1&#x3001; &#x5E76;&#x4E0D;&#x662F;&#x6240;&#x6709;&#x7684;&#x786C;&#x4EF6;&#x8BBE;&#x5907;&#x90FD;&#x6709;&#x6807;&#x51C6;&#x7684; linux kernel &#x7684;&#x63A5;&#x53E3;&#x3002;</p>
<p>2&#x3001; Kernel driver&#x6D89;&#x53CA;&#x5230;GPL&#x7684;&#x7248;&#x6743;&#x3002;&#x67D0;&#x4E9B;&#x8BBE;&#x5907;&#x5236;&#x9020;&#x5546;&#x5E76;&#x4E0D;&#x613F;&#x610F;&#x516C;&#x5F00;&#x786C;&#x4EF6;&#x9A71;&#x52A8;&#xFF0C;&#x6240;&#x4EE5;&#x624D;&#x901A;&#x8FC7;HAL&#x65B9;&#x5F0F;&#x7ED5;&#x8FC7;GPL&#x3002;</p>
<p>3&#x3001; &#x9488;&#x5BF9;&#x67D0;&#x4E9B;&#x786C;&#x4EF6;&#xFF0C; Android&#x6709;&#x4E00;&#x4E9B;&#x7279;&#x6B8A;&#x7684;&#x9700;&#x6C42;&#x3002;</p>
<p>HAL&#x7B80;&#x4ECB;&#x53CA;&#x73B0;&#x72B6;&#x5206;&#x6790;</p>
<p>&#x73B0;&#x6709;HAL&#x67B6;&#x6784;&#x7531; Patrick Brady (Google) &#x5728;2008G l oogle I/O&#x6F14;&#x8BB2;&#x4E2D;&#x63D0;&#x51FA;&#xFF0C; &#x4ECE;&#x4E0A;&#x9762;&#x67B6;&#x6784;&#x56FE;&#x6211;&#x4EEC;&#x77E5;&#x9053;&#xFF0C;HAL &#x7684;&#x76EE;&#x7684;&#x662F;&#x4E3A;&#x4E86;&#x628A; Android framework &#x4E0E;Linux kernel &#x5B8C;&#x6574;&#x300C;&#x9694;&#x5F00;&#x300D;&#x3002;&#x8BA9; Android &#x4E0D;&#x81F3;&#x8FC7;&#x5EA6;&#x4F9D;&#x8D56; Linux kernel&#xFF0C; &#x6709;&#x70B9;&#x300C;kernel independent&#x300D;&#x7684;&#x610F;&#x601D;&#x3002;</p>
<p>AL&#x7B80;&#x4ECB;&#x53CA;&#x73B0;&#x72B6;&#x5206;&#x6790;</p>
<p>HAL &#x4E3B;&#x8981;&#x7684;&#x5B9E;&#x73B0;&#x50A8;&#x5B58;&#x4E8E;&#x4EE5;&#x4E0B;&#x76EE;&#x5F55;</p>
<p>libhardware_legacy/ &#x2010; &#x65E7;&#x7684;&#x67B6;&#x6784;&#x3001; &#x91C7;&#x53D6;&#x94FE;&#x63A5;&#x5E93;&#x6A21;&#x5757;&#x7684;&#x89C2;&#x5FF5;&#x8FDB;&#x884C;</p>
<p>libhardware/ &#x2010; &#x65B0;&#x67B6;&#x6784;&#x3001;&#x8C03;&#x6574;&#x4E3A; HAL stub &#x7684;&#x89C2;&#x5FF5;</p>
<p>&#x65E7;&#x7684;HAL &#x67B6;&#x6784;(libhardware_legacy)</p>
<p>libhardware_legacy &#x4F5C;&#x6CD5;&#xFF0C;&#x662F;&#x4F20;&#x7EDF;&#x7684;&#x300C;module&#x300D;&#x65B9;&#x5F0F;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5C06; *.so &#x6587;&#x4EF6;&#x5F53;&#x505A;&#x300C;shared library&#x300D;&#x6765;&#x4F7F;&#x7528;&#xFF0C;&#x5728;runtime&#xFF08;JNI &#x90E8;&#x4EFD;&#xFF09; &#x4EE5; direct functioncall &#x4F7F;&#x7528; HAL module&#x3002;&#x901A;&#x8FC7;<strong>&#x76F4;&#x63A5;&#x8C03;&#x7528;&#x51FD;&#x6570;</strong>&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x6765;&#x64CD;&#x4F5C;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x3002;</p>
<p>&#x5F53;&#x7136;&#xFF0C;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x4E5F;&#x53EF;&#x4EE5;&#x4E0D;&#x9700;&#x8981;&#x901A;&#x8FC7; JNI &#x7684;&#x65B9;&#x5F0F;&#x8FDB;&#x884C;&#xFF0C; &#x76F4;&#x63A5;&#x52A0;&#x8F7D; <em>.so &#x5E93;&#xFF08;dlopen&#xFF09;&#x7684;&#x505A;&#x6CD5;&#x8C03;&#x7528;</em>.so &#x91CC;&#x7684;&#x7B26;&#x53F7;&#xFF08;symbol&#xFF09;&#x4E5F;&#x662F; &#x4E00;&#x79CD;&#x65B9;&#x5F0F;&#x3002;</p>
<p>&#x603B;&#x800C;&#x8A00;&#x4E4B;&#x662F;&#x6CA1;&#x6709;&#x7ECF;&#x8FC7;&#x5C01;&#x88C5;&#xFF0C;&#x4E0A;&#x5C42;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x64CD;&#x4F5C;&#x786C;&#x4EF6;&#x3002;</p>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706134945.png" alt="image-20200706134945797"></p>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706135452.png" alt="image-20200706135452501"></p>
<p>&#x65B0;&#x7684;HAL &#x67B6;&#x6784;(libhardware)</p>
<p>&#x73B0;&#x5728;&#x7684; libhardware &#x67B6;&#x6784;&#xFF0C;&#x5C31;&#x6709;&#x300C;stub&#x300D;&#x7684;&#x5473;&#x9053;&#x4E86;&#x3002; HAL stub &#x662F;&#x4E00;&#x79CD;&#x4EE3;&#x7406;&#x4EBA;&#xFF08;proxy&#xFF09; &#x7684;&#x6982;&#x5FF5;&#xFF0C; stub &#x867D;&#x7136;&#x4ECD;&#x662F;&#x4EE5; *.so&#x7684;&#x5F62;&#x5F0F;&#x5B58;&#x5728;&#xFF0C;&#x4F46; HAL &#x5DF2;&#x7ECF;&#x5C06; *.so &#x9690;&#x85CF;&#x8D77;&#x6765;&#x4E86;&#x3002; Stub &#x5411; HAL&#x300C;&#x63D0;&#x4F9B;&#x300D; &#x64CD;&#x4F5C;&#x51FD;&#x6570;&#xFF08;operations&#xFF09; &#xFF0C;&#x800C; runtime &#x5219;&#x662F;&#x5411; HAL &#x53D6;&#x5F97;&#x7279;&#x5B9A;&#x6A21;&#x5757;&#xFF08;stub&#xFF09;&#x7684; operations&#xFF0C;&#x518D; callback&#x8FD9;&#x4E9B;&#x64CD;&#x4F5C;&#x51FD;&#x6570;&#x3002; &#x8FD9;&#x79CD;&#x4EE5; indirect function call &#x7684;&#x67B6;&#x6784;&#xFF0C;&#x8BA9;HAL stub &#x53D8;&#x6210;&#x662F;&#x4E00;&#x79CD;&#x300C;&#x5305;&#x542B;&#x300D;&#x5173;&#x7CFB;&#xFF0C;&#x5373; HAL &#x91CC;&#x5305;&#x542B;&#x4E86;&#x8BB8;&#x8BB8;&#x591A;&#x591A;&#x7684; stub&#xFF08;&#x4EE3;&#x7406;&#x4EBA;&#xFF09; &#x3002;Runtime &#x53EA;&#x8981;&#x8BF4;&#x660E;&#x300C;&#x7C7B;&#x578B;&#x300D;&#xFF0C;&#x5373;module ID&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x53D6;&#x5F97;&#x64CD;&#x4F5C;&#x51FD;&#x6570;&#x3002;</p>
<p>&#x5BF9;&#x4E8E;&#x76EE;&#x524D;&#x7684;HAL&#xFF0C; &#x53EF;&#x4EE5;&#x8BA4;&#x4E3A;Android&#x5B9A;&#x4E49;&#x4E86;HAL&#x5C42;&#x7ED3;&#x6784;&#x6846;&#x67B6;&#xFF0C;&#x901A;&#x8FC7;&#x51E0;&#x4E2A;&#x63A5;&#x53E3;&#x8BBF;&#x95EE;&#x786C;&#x4EF6;&#x4ECE;&#x800C;&#x7EDF;&#x4E00;&#x4E86;&#x8C03;&#x7528;&#x65B9;&#x5F0F;&#x3002;</p>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706135547.png" alt="image-20200706135547846"></p>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706135611.png" alt="image-20200706135611185"></p>
<p>HAL_legacy&#x548C;HAL&#x7684;&#x5BF9;&#x6BD4;</p>
<ul>
<li>HAL_legacy&#xFF1A;&#x65E7;&#x5F0F;&#x7684;HAL&#x662F;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#xFF0C;&#x91C7;&#x7528;<strong>&#x5171;&#x4EAB;&#x5E93;</strong>&#x5F62;&#x5F0F;&#xFF0C;&#x5728;&#x7F16;&#x8BD1;&#x65F6;&#x4F1A;&#x8C03;&#x7528;&#x5230;&#x3002; &#x7531;&#x4E8E;&#x91C7;&#x7528; function call &#x5F62;&#x5F0F;&#x8C03;&#x7528;&#xFF0C;&#x56E0;&#x6B64;&#x53EF;&#x88AB;&#x591A;&#x4E2A;&#x8FDB;&#x7A0B;&#x4F7F;&#x7528;&#xFF0C;&#x4F46;&#x4F1A;&#x88AB; mapping &#x5230;&#x591A;&#x4E2A;&#x8FDB;&#x7A0B;&#x7A7A;&#x95F4;&#x4E2D;&#xFF0C; &#x540C;&#x65F6;&#x9700;&#x8981;&#x8003;&#x8651;&#x4EE3;&#x7801;&#x80FD;&#x5426;&#x5B89;&#x5168;&#x91CD;&#x5165;&#x7684;&#x95EE;&#x9898;&#xFF08;thread safe&#xFF09;&#x3002;</li>
<li>HAL&#xFF1A; &#x65B0;&#x5F0F;&#x7684;HAL&#x91C7;&#x7528; <strong>HAL module</strong> &#x548C; <strong>HAL stub</strong> &#x7ED3;&#x5408;&#x5F62;&#x5F0F;&#xFF0C;HAL stub&#x4E0D;&#x662F;&#x4E00;&#x4E2A;share library&#xFF0C;&#x7F16;&#x8BD1;&#x65F6;&#x4E0A;&#x5C42;&#x53EA;&#x62E5;&#x6709;&#x8BBF;&#x95EE;HAL stub&#x7684;&#x51FD;&#x6570;&#x6307;&#x9488;&#xFF0C; &#x5E76;&#x4E0D;&#x9700;&#x8981;HAL stub&#x3002; &#x4E0A;&#x5C42;&#x901A;&#x8FC7;HAL module&#x63D0;&#x4F9B;&#x7684;&#x7EDF;&#x4E00;&#x63A5;&#x53E3;&#x83B7;&#x53D6;&#x5E76;&#x64CD;&#x4F5C;HAL stub&#xFF0C;so&#x6587;&#x4EF6;&#x53EA;&#x4F1A;&#x88AB;mapping&#x5230;&#x4E00;&#x4E2A;&#x8FDB;&#x7A0B;&#xFF0C; &#x4E5F;&#x4E0D;&#x5B58;&#x5728;&#x91CD;&#x590D;mapping&#x548C;&#x91CD;&#x5165;&#x95EE;&#x9898;&#x3002;</li>
</ul>
<p>HAL_legacy&#x548C;HAL&#x7684;&#x5BF9;&#x6BD4;</p>
<p>Module</p>
<p>&#x89D2;&#x8272;&#x662F;&#x88AB;&#x8C03;&#x7528; , &#x5728;Android&#x67B6;&#x6784;&#x91CC;&#x9762;&#x4EC5;&#x4F5C;&#x4E3A;&#x7A0B;&#x5E8F;&#x5E93;(library)&#x7528;&#x9014;</p>
<p>Stub</p>
<p>Stub&#x53C8;&#x79F0;&#x4E3A;&#x4EE3;&#x7406;&#x4EBA;(proxy) , &#x626E;&#x6F14;&#x64CD;&#x4F5C;&#x4F9B;&#x5E94;&#x8005;&#x7684;&#x6982;&#x5FF5;(operations provider)</p>
<p>HAL_legacy&#x548C;HAL&#x7684;&#x5BF9;&#x6BD4;</p>
<p>HAL stub&#x7684;&#x6846;&#x67B6;&#x6BD4;&#x8F83;&#x7B80;&#x5355;&#xFF1A; &#x4E09;&#x4E2A;&#x7ED3;&#x6784;&#x4F53;&#x3001; &#x4E24;&#x4E2A;&#x5E38;&#x91CF;&#x3001; &#x4E00;&#x4E2A;&#x51FD;&#x6570;</p>
<p>&#x5B83;&#x7684;&#x5B9A;&#x4E49;&#x5728;&#xFF1A;</p>
<pre><code class="lang-text"> hardware/libhardware/include/hardware/hardware.h
 hardware/libhardware/hardware.c
</code></pre>
<p>HAL Stub&#x67B6;&#x6784;&#x5206;&#x6790;</p>
<pre><code class="lang-text"> /*
 &#x6BCF;&#x4E2A;&#x4E00;&#x4E2A;HAL Stub&#x90FD;&#x901A;&#x8FC7; hw_module_t &#x6765;&#x63CF;&#x8FF0;&#xFF0C; &#x6211;&#x4EEC;&#x79F0;&#x4E4B;&#x4E3A;&#x4E00;&#x4E2A;Stub&#x5BF9;&#x8C61;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x53BB;&#x201C; &#x7EE7;&#x627F; &#x201D;&#x8FD9;&#x4E2A; hw_module_t&#xFF0C;&#x7136;&#x540E;&#x6269;&#x5C55;&#x81EA;&#x5DF1;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x8FD9;&#x4E2A;HAL Stub&#x5BF9;&#x8C61;&#x5FC5;&#x987B;&#x5B9A;&#x4E49;&#x4E3A;&#x4E00;&#x4E2A;&#x56FA;&#x5B9A;&#x7684;&#x540D;&#x5B57;&#xFF1A;HMI( Hardware Module Information ) &#xFF0C;&#x6BCF;&#x4E00;&#x4E2A;Stub&#x5BF9;&#x8C61;&#x91CC;&#x90FD;&#x5C01;&#x88C5;&#x4E86;&#x4E00;&#x4E2A;&#x51FD;&#x6570;open&#xFF0C;&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x6765;&#x6253;&#x5F00;&#x8FD9;&#x4E2A;&#x786C;&#x4EF6;Stub&#x8BBE;&#x5907;&#xFF0C;&#x8FD4;&#x56DE;&#x8FD9;&#x4E2A;&#x786C;&#x4EF6;&#x5BF9;&#x5E94;&#x7684;Operation interface&#x3002;
 */
 struct hw_module_t;
</code></pre>
<pre><code class="lang-text"> /*
 HAL Stub&#x5BF9;&#x8C61;&#x7684;open&#x63CF;&#x8FF0;&#x7ED3;&#x6784;&#x4F53;&#xFF0C; &#x5B83;&#x91CC;&#x9762;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#xFF1A; open&#x51FD;&#x6570;&#x6307;&#x9488;
 */
 struct hw_module_methods_t;
 &#x200B;
 /*
 &#x7531;&#x7ED3;&#x6784;&#x4F53;hw_module_t&#x53EF;&#x77E5;&#xFF0C;&#x5B83;&#x7684;open&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x786C;&#x4EF6;&#x5BF9;&#x5E94;&#x7684;Operation interface&#xFF0C; &#x8FD9;&#x4E2A;&#x786C;&#x4EF6;&#x7684;operation interface&#x7684;&#x63CF;&#x8FF0;&#x7531;hw_device_t &#x7ED3;&#x6784;&#x4F53;&#x6765;&#x63CF;&#x8FF0;
 */
 struct hw_device_t;
</code></pre>
<pre><code class="lang-text"> // &#x8FD9;&#x4E2A;&#x5C31;&#x662F;HAL Stub&#x5BF9;&#x8C61;&#x56FA;&#x5B9A;&#x7684;&#x540D;&#x5B57;
 #define HAL_MODULE_INFO_SYM HMI
 // &#x8FD9;&#x4E2A;&#x662F;&#x4EE5;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x540D;&#x5B57;
 #define HAL_MODULE_INFO_SYM_AS_STR &quot;HMI&quot;
 //&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x662F;&#x901A;&#x8FC7;&#x786C;&#x4EF6;&#x540D;&#x6765;&#x83B7;&#x5F97;&#x786C;&#x4EF6;HAL Stub&#x5BF9;&#x8C61;
 int hw_get_module(const char *id, const struct hw_module_t **module);
</code></pre>
<pre><code class="lang-text"> //&#x6CE8;&#x518C;&#x4E00;&#x4E2A;Stub&#x5BF9;&#x8C61;
 const struct led_modulet_HAL_MODULE_INFO_SYM = {
     common: {
     tag: HARDWARE_MODULE_TAG,
     version_major: 1,
     version_minor: 0,
     id: LED_HARDWARE_MODULE_ID,
     name: &quot;led HAL Stub&quot;,
     author: &quot;farsight&quot;,
     methods: &amp;led_module_methods,
     },
     // &#x6269;&#x5C55;&#x5C5E;&#x6027;&#x653E;&#x5728;&#x8FD9;&#x513F;
 }
</code></pre>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706135929.png" alt="image-20200706135929366"></p>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706135949.png" alt="image-20200706135949036"></p>
<h4 id="android&#x91CC;&#x7684;jni&#x8C03;&#x7528;&#x673A;&#x5236;">Android&#x91CC;&#x7684;Jni&#x8C03;&#x7528;&#x673A;&#x5236;</h4>
<p>JVM &#x5F88;&#x597D;&#x7684;&#x89E3;&#x51B3;java&#x7684;&#x53EF;&#x79FB;&#x690D;&#x6027;&#x95EE;&#x9898;&#xFF0C;&#x4F7F;&#x5F97;java&#x8F6F;&#x4EF6;&#x53EF;&#x4EE5;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x786C;&#x4EF6;&#x5E73;&#x53F0;&#x4E0B;&#x8FD0;&#x884C;&#xFF0C;&#x4F46;&#x662F;JVM&#x4E0D;&#x662F;&#x4E07;&#x80FD;&#x7684;&#xFF0C;&#x6BD5;&#x7ADF;&#x5B83;&#x53EA;&#x662F;&#x4E00;&#x4E2A;&#x6A21;&#x62DF;&#x73AF;&#x5883;&#xFF0C;&#x5BF9;&#x4E8E;&#x4E00;&#x4E9B;&#x5916;&#x56F4;&#x7684;&#x786C;&#x4EF6;&#x5C31;&#x5F88;&#x96BE;&#x6A21;&#x62DF;&#xFF0C; JVM&#x53EA;&#x662F;&#x6A21;&#x62DF;&#x4E86;&#x4E00;&#x90E8;&#x5206;&#x7684;&#x5BC4;&#x5B58;&#x5668;&#xFF0C; &#x6808;&#x7ED3;&#x6784;&#xFF0C; JVM&#x50A8;&#x5B58;&#x5668;&#xFF0C;&#x8FD9;&#x4E9B;&#x90FD;&#x662F;&#x8F6F;&#x4EF6;&#x8FD0;&#x884C;&#x7684;&#x57FA;&#x7840;&#x786C;&#x4EF6;&#x7ED3;&#x6784;&#x3002;</p>
<p>&#x5BF9;&#x4E8E;&#x50CF;android&#x624B;&#x673A;&#x8FD9;&#x6837;&#x7684;&#x5E73;&#x53F0;&#xFF0C; &#x6709;&#x5F88;&#x591A;&#x7684;&#x5916;&#x56F4;&#x8BBE;&#x5907;&#x5728;&#x8F6F;&#x4EF6;&#x5C42;&#x662F;&#x9700;&#x8981;&#x64CD;&#x4F5C;&#x7684;&#xFF0C;&#x5982;wifi&#xFF0C;&#x84DD;&#x7259;&#xFF0C;&#x89E6;&#x6478;&#x5C4F;&#xFF0C;&#x91CD;&#x529B;&#x611F;&#x5E94;&#xFF0C;&#x952E;&#x76D8;&#x7B49;&#xFF0C;&#x5982;&#x679C;&#x76F4;&#x63A5;&#x901A;&#x8FC7;java&#x8BED;&#x8A00;&#x64CD;&#x4F5C;&#x662F;&#x5F88;&#x96BE;&#x5B9E;&#x73B0;&#x7684;&#xFF0C; JVM&#x65E0;&#x6CD5;&#x6A21;&#x62DF;&#x8FD9;&#x4E9B;&#x786C;&#x4EF6;&#x3002;</p>
<p>JNI( Java Native Interface )&#xFF0C; &#x4E2D;&#x6587;&#x4E3A;JAVA&#x672C;&#x5730;&#x8C03;&#x7528;&#x3002; &#x4ECE;Java1.1&#x5F00;&#x59CB;&#xFF0C;Java Native Interface( JNI )&#x6807;&#x51C6;&#x6210;&#x4E3A;java&#x5E73;&#x53F0;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x5B83;&#x5141;&#x8BB8;Java&#x4EE3;&#x7801; &#x548C; &#x5176;&#x4ED6;&#x8BED;&#x8A00;&#x5199;&#x7684;&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x4EA4;&#x4E92;&#x3002; JNI&#x4E00;&#x5F00;&#x59CB;&#x662F;&#x4E3A;&#x4E86;&#x672C;&#x5730;&#x5DF2;&#x7F16;&#x8BD1;&#x8BED;&#x8A00;&#xFF0C; &#x5C24;&#x5176;&#x662F; C &#x548C; C++ &#x800C;&#x8BBE;&#x8BA1;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x5B83;&#x5E76;&#x4E0D;&#x59A8;&#x788D;&#x4F60;&#x4F7F;&#x7528;&#x5176;&#x4ED6;&#x8BED;&#x8A00;&#xFF0C;&#x53EA;&#x8981;&#x8C03;&#x7528;&#x7EA6;&#x5B9A;&#x53D7;&#x652F;&#x6301;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;&#x4F7F;&#x7528; java &#x4E0E;&#x672C;&#x5730;&#x5DF2;&#x7F16;&#x8BD1;&#x7684;&#x4EE3;&#x7801;&#x4EA4;&#x4E92;&#xFF0C;&#x901A;&#x5E38;&#x4F1A;&#x4E27;&#x5931;&#x5E73;&#x53F0;&#x53EF;&#x79FB;&#x690D;&#x6027;&#x3002;</p>
<p>&#x4F46;&#x662F;&#xFF0C; &#x6709;&#x4E9B;&#x4E9B;&#x60C5;&#x51B5;&#x4E0B;&#x8FD9;&#x6837;&#x505A;&#x662F;&#x53EF;&#x4EE5;&#x63A5;&#x53D7;&#x7684;&#xFF0C; &#x751A;&#x81F3;&#x662F;&#x5FC5;&#x987B;&#x7684;&#xFF0C;&#x6BD4;&#x5982;&#xFF0C; &#x4F7F;&#x7528;&#x4E00;&#x4E9B;&#x65E7;&#x7684;&#x5E93;&#xFF0C;&#x4E0E;&#x786C;&#x4EF6;&#x3001;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x8FDB;&#x884C;&#x4EA4;&#x4E92;&#xFF0C;&#x6216;&#x8005;&#x4E3A;&#x4E86;&#x63D0;&#x9AD8;&#x7A0B;&#x5E8F;&#x7684;&#x6027;&#x80FD;&#x3002; JNI&#x6807;&#x51C6;&#x81F3;&#x5C11;&#x4FDD;&#x8BC1;&#x672C;&#x5730;&#x4EE3;&#x7801;&#x80FD;&#x5DE5;&#x4F5C;&#x5728;&#x4EFB;&#x4F55;Java&#x865A;&#x62DF;&#x673A;&#x5B9E;&#x73B0;&#x4E0B;&#x3002;</p>
<p><img src="https://gitee.com/cpu_code/picture_bed/raw/master//20200706140038.png" alt="image-20200706140038704"></p>
<p>Jni&#x5728; Java&#x548C;C&#x3001; C++&#x7B49;&#x8BED;&#x8A00;&#x4E4B;&#x95F4;&#x5EFA;&#x7ACB;&#x4E86;&#x4E00;&#x4E2A;<strong>&#x6865;&#x6881;&#x4F5C;&#x7528;</strong>&#xFF0C;&#x56E0;&#x6B64;&#xFF0C; JNI&#x9996;&#x5148;&#x8981;&#x505A;&#x7684;&#xFF0C;&#x5C31;&#x662F;&#x7EDF;&#x4E00;&#x4E24;&#x8005;&#x95F4;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x3002;</p>
<p>&#x6240;&#x6709;&#x5176;&#x5B83;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#xFF0C;&#x5728;JNI&#x4E2D;&#x90FD;&#x88AB;&#x5B9A;&#x4E49;&#x4E3A; jobject &#x7C7B;&#x578B;&#xFF0C;&#x5728;C&#x4E2D;&#x90FD;&#x5B9A;&#x4E49;&#x4E3A; void*&#x3002;</p>
<table>
<thead>
<tr>
<th style="text-align:left">Java Language Type</th>
<th style="text-align:left">JNI Type</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">boolean</td>
<td style="text-align:left">jboolean</td>
</tr>
<tr>
<td style="text-align:left">byte</td>
<td style="text-align:left">jbyte</td>
</tr>
<tr>
<td style="text-align:left">char</td>
<td style="text-align:left">jchar</td>
</tr>
<tr>
<td style="text-align:left">short</td>
<td style="text-align:left">jshort</td>
</tr>
<tr>
<td style="text-align:left">int</td>
<td style="text-align:left">jint</td>
</tr>
<tr>
<td style="text-align:left">long</td>
<td style="text-align:left">jlong</td>
</tr>
<tr>
<td style="text-align:left">float</td>
<td style="text-align:left">jfloat</td>
</tr>
<tr>
<td style="text-align:left">double</td>
<td style="text-align:left">jdouble</td>
</tr>
</tbody>
</table>
<p>Java&#x4E2D;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x8C03;&#x7528;&#x5E95;&#x5C42;&#x8BED;&#x8A00;&#x7684;&#x51FD;&#x6570;&#x6216;&#x65B9;&#x6CD5;&#xFF0C; Jni&#x89C4;&#x5B9A;&#x4E86;Java&#x8C03;&#x7528;&#x5E95;&#x5C42;&#x8BED;&#x8A00;&#x7684;&#x65B9;&#x6CD5;&#x7B7E;&#x540D;&#x89C4;&#x8303;&#x3002;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x7C7B;&#x578B;&#x7B7E;&#x540D;</th>
<th style="text-align:left">Java &#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x7C7B;&#x578B;&#x7B7E;&#x540D;</th>
<th style="text-align:left">Java &#x7C7B;&#x578B;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">Z</td>
<td style="text-align:left">boolean</td>
<td style="text-align:left">[</td>
<td style="text-align:left">[]</td>
</tr>
<tr>
<td style="text-align:left">B</td>
<td style="text-align:left">byte</td>
<td style="text-align:left">[I</td>
<td style="text-align:left">int[]</td>
</tr>
<tr>
<td style="text-align:left">C</td>
<td style="text-align:left">char</td>
<td style="text-align:left">[F</td>
<td style="text-align:left">float[]</td>
</tr>
<tr>
<td style="text-align:left">S</td>
<td style="text-align:left">short</td>
<td style="text-align:left">[B</td>
<td style="text-align:left">byte[]</td>
</tr>
<tr>
<td style="text-align:left">I</td>
<td style="text-align:left">int</td>
<td style="text-align:left">[C</td>
<td style="text-align:left">char[]</td>
</tr>
<tr>
<td style="text-align:left">J</td>
<td style="text-align:left">long</td>
<td style="text-align:left">[S</td>
<td style="text-align:left">short[]</td>
</tr>
<tr>
<td style="text-align:left">F</td>
<td style="text-align:left">float</td>
<td style="text-align:left">[D</td>
<td style="text-align:left">double[]</td>
</tr>
<tr>
<td style="text-align:left">D</td>
<td style="text-align:left">double</td>
<td style="text-align:left">[J</td>
<td style="text-align:left">long[]</td>
</tr>
<tr>
<td style="text-align:left">L</td>
<td style="text-align:left">fully-qualified-class&#xFF08;&#x5168;&#x9650;&#x5B9A;&#x7684;&#x7C7B;&#xFF09;</td>
<td style="text-align:left">[Z</td>
<td style="text-align:left">boolean[]</td>
</tr>
</tbody>
</table>
<p>Android&#x91CC;&#x7684;Jni&#x8C03;&#x7528;&#x673A;&#x5236;</p>
<ul>
<li>&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x901A;&#x5E38;&#x662F;&#x4EE5;&#x4E0B;&#x7ED3;&#x6784;&#xFF1A; &#x8FD4;&#x56DE;&#x503C; fun(&#x53C2;&#x6570;1&#xFF0C;&#x53C2;&#x6570;2&#xFF0C;&#x53C2;&#x6570;3&#xFF09; ;</li>
<li>&#x5176;&#x5BF9;&#x5E94;&#x7684;Jni&#x65B9;&#x6CD5;&#x7B7E;&#x540D;&#x683C;&#x5F0F;&#x4E3A;&#xFF1A; (&#x53C2;&#x6570;1&#x53C2;&#x6570;2&#x53C2;&#x6570;3)&#x8FD4;&#x56DE;&#x503C;</li>
<li>&#x6CE8;&#x610F;&#xFF1A;</li>
</ul>
<p>&#x51FD;&#x6570;&#x540D;&#xFF0C;&#x5728;Jni&#x4E2D;&#x6CA1;&#x6709;&#x4F53;&#x73B0;&#x51FA;&#x6765;</p>
<p>&#x53C2;&#x6570;&#x5217;&#x8868;&#x76F8;&#x6328;&#x7740;&#xFF0C; &#x4E2D;&#x95F4;&#x6CA1;&#x6709;&#x9017;&#x53F7;&#xFF0C; &#x6CA1;&#x6709;&#x7A7A;&#x683C;</p>
<p>&#x8FD4;&#x56DE;&#x503C;&#x51FA;&#x73B0;&#x5728;&#xFF08;&#xFF09;&#x540E;&#x9762;</p>
<p>&#x5982;&#x679C;&#x53C2;&#x6570;&#x662F;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#xFF0C; &#x90A3;&#x4E48;&#x53C2;&#x6570;&#x5E94;&#x8BE5;&#x4E3A;&#xFF1A; L&#x7C7B;&#x578B;;</p>
<p>HAL Led&#x8C03;&#x7528;&#x6D41;&#x7A0B;</p>
<pre><code class="lang-text">/LedDemo/Led Service(java)/Led Service(Native)/Led HAL Stub1:&#x521B;&#x5EFA;&#x670D;&#x52A1;&#x5BF9;&#x8C61;&lt;&lt;create&gt;&gt;2:&#x901A;&#x8FC7;JNI&#x521D;&#x59CB;&#x5316;&#x672C;&#x5730;&#x670D;&#x52A1;()3: &#x67E5;&#x627E;&#x5E76;&#x5F97;&#x5230;HAL&#x64CD;&#x4F5C;&#x63A5;&#x53E3;()4:&#x8FD4;&#x56DE;device&#x64CD;&#x4F5C;&#x63A5;&#x53E3;5:&#x64CD;&#x4F5C;service&#x63D0;&#x4F9B;&#x7684;API()6: &#x901A;&#x8FC7;JNI&#x8C03;&#x7528;&#x672C;&#x5730;&#x670D;&#x52A1;&#x64CD;&#x4F5C;&#x63A5;&#x53E3;()7: &#x8C03;&#x7528;&#x4FDD;&#x5B58;&#x7684;devicer&#x64CD;&#x4F5C;&#x63A5;&#x53E3;()8: &#x8FD4;&#x56DE;HAL&#x64CD;&#x4F5C;&#x7ED3;&#x679C;9: &#x8FD4;&#x56DE;&#x672C;&#x5730;&#x670D;&#x52A1;&#x64CD;&#x4F5C;&#x7ED3;&#x679C;10: &#x8FD4;&#x56DE;&#x6846;&#x67B6;&#x670D;&#x52A1;&#x64CD;&#x4F5C;&#x7ED3;&#x679C;/LedDemo/Led Service(java)/Led Service(Native)/Led HAL Stub
</code></pre>
<pre><code class="lang-text">/Led APP/Led Service(java)/Led Service(Native)/Led HAL Stub1:new LedService()2:system.loadLibrary()3: JNI_OnLoad()&#x6CE8;&#x518C;java&#x65B9;&#x6CD5;&#x4E0E;&#x672C;&#x5730;&#x51FD;&#x6570;&#x7684;&#x6620;&#x5C04;&#x5173;&#x7CFB;4: _init()5: hw_get_module()6: Return module_t object7: callback module_t open interface()8: Return device_t operations9: LedService.set_on/set_off()10: _set_on, _set_off()11: devict_t-&gt;set_on/set_off()/Led APP/Led Service(java)/Led Service(Native)/Led HAL Stub
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; dsx2016.com 2019 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x7AE0;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2020-07-12 21:08:49
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="AOSP.html" class="navigation navigation-prev " aria-label="Previous page: AOSP源码开发">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../operating_system/operat_mechanism.html" class="navigation navigation-next " aria-label="Next page: 操作系统的运行机制">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Android底层软硬件结合开发概述","level":"3.4","depth":1,"next":{"title":"操作系统的运行机制","level":"4.1","depth":1,"path":"operating_system/operat_mechanism.md","ref":"operating_system/operat_mechanism.md","articles":[]},"previous":{"title":"AOSP源码开发","level":"3.3","depth":1,"path":"android_bottom/AOSP.md","ref":"android_bottom/AOSP.md","articles":[]},"dir":"ltr"},"config":{"plugins":["back-to-top-button","chapter-fold","code","splitter","-lunr","-search","search-pro","insert-logo","custom-favicon","pageview-count","tbfed-pagefooter","popup","-sharing","sharing-plus","livereload"],"root":".","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy dsx2016.com 2019","modify_label":"该文章修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"livereload":{},"splitter":{},"search-pro":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"popup":{},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"favicon":"./icon/book.ico","back-to-top-button":{},"pageview-count":{},"custom-favicon":{},"sharing":{"qq":true,"all":["douban","facebook","google","instapaper","linkedin","twitter","weibo","messenger","qq","qzone","viber","whatsapp"],"douban":true,"facebook":true,"weibo":true,"twitter":true,"pocket":true,"google":true,"qzone":true},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"insert-logo":{"style":"background: none; max-height: 30px; min-height: 30px","url":"https://s1.ax1x.com/2020/06/18/Nnpxmj.png"}},"theme":"default","author":"cpucode","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GItBook笔记","language":"zh-hans","output.name":"site","links":{"sidebar":{"首页":"https://blog.csdn.net/qq_44226094"}},"gitbook":"3.2.3","description":"GitBook笔记"},"file":{"path":"android_bottom/summary.md","mtime":"2020-07-12T13:08:49.570Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-07-15T02:25:37.570Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

